Page({

  /**
   * 页面的初始数据
   */
  data: {
    remark: '',
    maxLength: 100,
    currentLength: 0
  },
  save() {
    this.setData({
      remark: this.data.remark.trim()
    });
    this.setData({
      currentLength: this.data.remark.length
    });
    let pages = getCurrentPages(), prevPage = pages[pages.length - 2];
    prevPage.toggle('act.remark', this.data.remark);
    prevPage.toggle('remarkStr', this.subRemark(this.data.remark));
    wx.navigateBack({
      delta: 1
    })
  },
  subRemark(str){
    if(str.length > 10){
      return str.substring(0, 10)+'...';
    }else{
      return str
    }
  },
  remarkInput(e) {
    var remark = e.detail.value, currentLength = e.detail.value.length;
    if (currentLength > this.data.maxLength) {
      wx.showToast({
        title: '输入文字数量已达到上限',
        icon: 'none',
        duration: 2000
      })
      return this.data.remark;
    }
    this.setData({
      remark: remark,
      currentLength: currentLength
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (options.remark && options.remark != '') {
      this.setData({
        remark: options.remark,
        currentLength: options.remark.length
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  }
})